package com.ruoyi.dispatch.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dispatch.domain.TunnelInfo;
import com.ruoyi.dispatch.service.ITunnelInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 巷道信息Controller
 * 
 * @author wuxiaofang
 * @date 2025-04-08
 */
@RestController
@RequestMapping("/dispatch/tunnelInfo")
@Anonymous
public class TunnelInfoController extends BaseController
{
    @Autowired
    private ITunnelInfoService tunnelInfoService;

    /**
     * 查询巷道信息列表
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:tunnelInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(TunnelInfo tunnelInfo)
    {
        startPage();
        List<TunnelInfo> list = tunnelInfoService.selectTunnelInfoList(tunnelInfo);
        return getDataTable(list);
    }

    /**
     * 导出巷道信息列表
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:tunnelInfo:export')")
    @Log(title = "巷道信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TunnelInfo tunnelInfo)
    {
        List<TunnelInfo> list = tunnelInfoService.selectTunnelInfoList(tunnelInfo);
        ExcelUtil<TunnelInfo> util = new ExcelUtil<TunnelInfo>(TunnelInfo.class);
        util.exportExcel(response, list, "巷道信息数据");
    }

    /**
     * 获取巷道信息详细信息
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:tunnelInfo:query')")
    @GetMapping(value = "/{tunnelId}")
    public AjaxResult getInfo(@PathVariable("tunnelId") Long tunnelId)
    {
        return success(tunnelInfoService.selectTunnelInfoByTunnelId(tunnelId));
    }

    /**
     * 新增巷道信息
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:tunnelInfo:add')")
    @Log(title = "巷道信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TunnelInfo tunnelInfo)
    {
        tunnelInfo.setCreateBy(getUsername());
        return toAjax(tunnelInfoService.insertTunnelInfo(tunnelInfo));
    }

    /**
     * 修改巷道信息
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:tunnelInfo:edit')")
    @Log(title = "巷道信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TunnelInfo tunnelInfo)
    {
        tunnelInfo.setUpdateBy(getUsername());
        return toAjax(tunnelInfoService.updateTunnelInfo(tunnelInfo));
    }

    /**
     * 删除巷道信息
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:tunnelInfo:remove')")
    @Log(title = "巷道信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tunnelIds}")
    public AjaxResult remove(@PathVariable Long[] tunnelIds)
    {
        return toAjax(tunnelInfoService.deleteTunnelInfoByTunnelIds(tunnelIds));
    }
}
